<?php
class ControllerShippingCitylink extends AdminController {

	protected $citylink_rate = '10:11.6,15:14.1,20:16.60,25:19.1,30:21.6,35:24.1,40:26.6,45:29.1,50:31.6,55:34.1,60:36.6,65:39.1,70:41.6,75:44.1,80:46.6,100:56.6,125:69.1,150:81.6,200:106.6';
	public function index() {

		$this->document->setTitle($this->_['heading_title']);

		M('setting/setting');

		if ($this->request->isPost() && $this->validate()) {
			$this->model_setting_setting->editSetting('citylink', $this->request->post);

			$this->session->set_flashdata('success', $this->_['text_success']);
			$this->redirect(UA('extension/shipping'));
		}

  		$this->data['breadcrumbs'] = array();

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['text_home'],
			'href'      => UA('common/home'),
      		'separator' => false
   		);

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['text_shipping'],
			'href'      => UA('extension/shipping'),
      		'separator' => ' :: '
   		);

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['heading_title'],
			'href'      => UA('shipping/citylink'),
      		'separator' => ' :: '
   		);

		$this->data['citylink_rate'] = $this->citylink_rate;

		M('localisation/tax_class');
		$this->data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();

		M('localisation/geo_zone');
		$this->data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();

		$this->display('shipping/citylink.tpl');
	}

	protected function validate() {
		if (!$this->hasMP()) {
			$this->setMessage('error_warning', $this->_['error_permission']);
			return false;
		}
		return true;
	}
}
?>